﻿@using MyData.Dto
@model ConfigMobileDto
@{
    ViewBag.Title = "ConfigMobile";
    Layout = "~/Views/Shared/_Index.cshtml";

}
<link href="~/Content/multi-select/css/multi-select.css" rel="stylesheet" />
<script src="~/Content/multi-select/js/jquery.multi-select.js"></script>
<div class="tools">
    <ul class="toolbar">
        <li class="click" onclick="fnSave()"><span><img src="../Content/UI/images/t02.png" /></span>保存</li>
    </ul>
</div>
<div class="formbody">
    
            <select id='pre-selected-options' multiple='multiple'>
                @{
                    foreach (var item in Model.ConfigMobiles)
                    {
                        if (item.IsSelected)
                        {
                            <option value='@item.Id' selected> @item.Name</option>
                        }
                        else
                        {
                            <option value='@item.Id'> @item.Name</option>
                        }
                    }
                }
            </select>
</div>
    <script type="text/javascript">
    // run pre selected options
    $('#pre-selected-options').multiSelect();
    function fnSave() {
        var result = $('#pre-selected-options').val();
        console.log(result)
        $.post("../Depart/SaveConfigMobile", { Id: '@Model.Id', Mobiles: result}, function (result) {
            if (result.state == 1) {
                layer.msg('操作成功');
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index)
                parent.$("#table").bootstrapTable('refresh');
            }
            else {
                layer.msg(result.message);
            }
        })
    }
    </script>
